package com.aaa.vegetablemarketexpress.service;

import com.aaa.vegetablemarketexpress.entity.ShopProduct;
import com.aaa.vegetablemarketexpress.util.Page;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @FileName: ShopProductService
 * @Description:
 * @Author: 张钰哲
 * @CreateTime: 2025/9/12 14:33
 * @Version: 1.0.0
 */

public interface ShopProductService {
    /**
     * 根据ID查询关联
     * @param id
     * @return
     */
    ShopProduct selectShopProductById(Long id);

    /**
     * 查询关联列表
     * @param page
     * @return
     */
    PageInfo<ShopProduct> selectShopProductList(Page<ShopProduct> page);

    /**
     * 根据店铺ID查询关联的商品ID列表
     * @param shopId
     * @return
     */
    List<Long> selectProductIdsByShopId(Long shopId);

    /**
     * 根据商品ID查询关联的店铺ID列表
     * @param productId
     * @return
     */
    List<Long> selectShopIdsByProductId(Long productId);

    /**
     * 新增店铺商品关联
     * @param shopProduct
     * @return
     */
    int insertShopProduct(ShopProduct shopProduct);

    /**
     * 批量新增关联
     * @param shopProductList
     * @return
     */
    int batchInsertShopProduct(List<ShopProduct> shopProductList);

    /**
     * 根据ID删除店铺商品关联
     * @param id
     * @return
     */
    int deleteShopProductById(Long id);

    /**
     * 根据店铺ID和商品ID删除关联
     * @param shopId
     * @param productId
     * @return
     */
    int deleteShopProduct(Long shopId, Long productId);

    /**
     * 根据店铺ID删除所有关联
     * @param shopId
     * @return
     */
    int deleteShopProductByShopId(Long shopId);

    /**
     * 根据商品ID删除所有关联
     * @param productId
     * @return
     */
    int deleteShopProductByProductId(Long productId);

    /**
     * 检查关联是否存在
     * @param shopId
     * @param productId
     * @return
     */
    int checkShopProductExist(Long shopId, Long productId);

    /**
     * 更新店铺的商品关联（先删除原有，再添加新的）
     * @param shopId
     * @param productIds
     * @return
     */
    int updateShopProducts(Long shopId, List<Long> productIds);
    /**
     * 为店铺添加商品（包含权限校验）
     */
    int addProductToShop(Long shopId, Long productId, Long currentUserId);
    // 检查关联是否存在
    ShopProduct selectShopProduct(Long shopId, Long productId);

    /**
     * 通过产品ID查询所属店铺名称
     * @param productId 产品ID
     * @return 店铺名称，若不存在则返回“无关联店铺”
     */
    String getShopNameByProductId(Long productId);

}
